{% extends "layouts/base.html" %}
{% load book_extras %}
{% block title %} Management {% endblock %} 

{% block stylesheets %}{% endblock stylesheets %}

{% block content %}

<div class="pcoded-content">
    <div class="pcoded-inner-content">
        <div class="page-header">
            <div class="page-block">
                <div class="row align-items-center">
                    <div class="col-md-12">
                        <div class="page-header-title">
                            <h5 class="m-b-10">出版商管理</h5>

                        </div>

                    </div>
                </div>
            </div>

        </div>

        <br>
        <!-- [ breadcrumb ] end -->
        <div class="main-body">
            <div class="page-wrapper">
                <!-- [ Main Content ] start -->
                <div class="row">
                    <!-- [ basic-table ] start -->
                    <div class="col-xl-12">
                        <div class="card">
                            <div class="card-header">
                                <h5>总共 {{count_total}} 种出版商</h5>
                            </div>
                            
                            {% show_messages %}
                            
                            <div class="card-block ">
                                <div class='row'>
                                    <div class="col-8">
                                        <b>排序方式： </b>
                                        <a href="{% url 'publisher_list' %}?search={{search}}&orderby=id">编号</a>  |
                                        <a href="{% url 'publisher_list' %}?search={{ search }}&orderby=name">姓名</a> |
                                        <a href="{% url 'publisher_list' %}?search={{ search }}&orderby=city">城市</a> |
                                        <a href="{% url 'publisher_list' %}?search={{ search }}&orderby=created_at">创建时间</a>
                                    </div>
   
                                    <div class="col-4">
                                        <form class="form-inline mb-2">
                                            <div class="form-group  mb-2">
                                                <input type="text" 
                                                       class="form-control" 
                                                       name="search",
                                                       id='search',
                                                       placeholder="Search...",
                                                       value={{search}}
                                                       >
                                            </div>
                                            <button type="submit" class="btn btn-secondary mb-2 ml-2 btn-sm">搜索</button>
                                        </form>
                                    </div>
                                </div>

                                <div class="table-responsive table-hover">
                                    <table class="table">
                                        <thead>
                                            <tr>
                                                <th>编号</th>
                                                <th>姓名</th>
                                                <th>城市</th>
                                                <th>电子邮箱</th>
                                                <th>创建时间</th>
                                                <th>更新者</th>
                                                <th>###</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            
                                            {% for pub in publishers %}
                                            <tr>
                                                <th scope="row">{{pub.id}}</th>
                                                <td>{{pub.name}}</td>
                                                <td>{{pub.city}}</td>
                                                <td>{{pub.contact}}</td>
                                                <td>{{ pub.created_at|date:"Y/m/d" }} </td>
                                                <td>{{ pub.updated_by}} at {{ pub.updated_at|date:"Y-m-d H:i" }}  </td>
                                                <td><a href="{% url 'publisher_update' pub.id%}" class="badge badge-info"><i class="feather icon-edit"></i>&nbsp;更新</a>
                                                    <a href="{% url 'publisher_delete' pub.pk %}" class="badge badge-danger"><i class="feather icon-trash-2"></i>&nbsp;删除</a>&nbsp;
                                                </td>

                                            </tr>
                                            {% endfor %}


                                        </tbody>
                                    </table>
                                </div>
                                <div class="row">
                                    <div class='col-6'>
                                        <a href="{% url 'publisher_create' %}" class='btn btn-primary'>添加出版商</a>
                                    </div>
                                    <div class='col-6'>
                                        {% show_pagination %}                                 
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                </div>
            </div>
        </div>
    </div>
</div>

{% endblock content %}

<!-- Specific Page JS goes HERE  -->
{% block javascripts %}{% endblock javascripts %}
